unit ArticleSearch;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TfmArticleSearch = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    edtTitle: TEdit;
    edtAuthor: TEdit;
    edtPaper_name: TEdit;
    edtPaper_year: TEdit;
    btnSearch: TButton;
    Label5: TLabel;
    edtBBK: TEdit;
    Label6: TLabel;
    edtComment: TEdit;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
    procedure btnSearchClick(Sender: TObject);
  private
    { Private declarations }
    procedure Search;
  public
    { Public declarations }
  end;

var
  fmArticleSearch: TfmArticleSearch;

implementation
uses ArticleSearchResult;
{$R *.DFM}

procedure TfmArticleSearch.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TfmArticleSearch.FormDestroy(Sender: TObject);
begin
  fmArticleSearch := nil;
end;

procedure TfmArticleSearch.Search;
var sql: string;
  resForm: TfmArticleSearchResult;
begin
  Application.CreateForm(TfmArticleSearchResult, resForm);
  resForm.IdsQuery.SQL.Text := 'select * from search_articles(:i_title, :i_author, :i_PaperName, :i_PaperYear, :i_BBK, :i_Comment)';
  resForm.IdsQuery.ParamByName('i_title').AsString      := edtTitle.Text;
  resForm.IdsQuery.ParamByName('i_author').AsString     := edtAuthor.Text;
  resForm.IdsQuery.ParamByName('i_PaperName').AsString  := edtPaper_name.Text;
  resForm.IdsQuery.ParamByName('i_PaperYear').AsString  := edtPaper_year.Text;
  resForm.IdsQuery.ParamByName('i_BBK').AsString        := edtBBK.Text;
  resForm.IdsQuery.ParamByName('i_comment').AsString    := edtComment.Text;
  resForm.OpenIdsQuery;
  resForm.Show;
end;

procedure TfmArticleSearch.btnSearchClick(Sender: TObject);
begin
  Search;
end;

end.
